home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / Sources / src / origami / set.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-27  |  1.9 KB  |  90 lines

  1. /*{{{}}}*/
  2. /*{{{  #includes*/
  3. #ifdef CONFIG_H
  4. #   include "config.h"
  5. #endif
  6.  
  7. #include <sys/types.h>
  8. #include <ctype.h>
  9. #include <limits.h>
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12.  
  13. #define SET_C
  14. #define I_INIT_C
  15. #define I_GETMSG_C
  16. #define I_MESSAGES_C
  17. #define I_SCREEN_C
  18. #define I_SIGNALS_C
  19.  
  20. #include "origami.h"
  21.  
  22. #include <h/rcformat.h>
  23. #include <lib/ori_rc_lib.h>
  24. #include <lib/ori_add_lib.h>
  25. /*}}}  */
  26.  
  27. /*{{{  variables*/
  28. private SetField *setlist=0;
  29. private int set_used=0;
  30. /*}}}  */
  31.  
  32. /*{{{  init_set*/
  33. public boolean init_set(void)
  34. { int no;
  35.   int lg;
  36.  
  37.   no=rc_get_w(rcfile);
  38.   set_used=no;
  39.   /*{{{  get bitmaps*/
  40.   if (no<=0 || !(setlist=paket_malloc(no*SET_LG)))
  41.    { eputs((unsigned char *)M_NO_MEMORY);
  42.      eputc('\n');
  43.      return(True);
  44.    }
  45.   while (no--)
  46.      rc_nget_c(rcfile,SET_LG,setlist[no]);
  47.   /*}}}  */
  48.   /*{{{  get names*/
  49.   lg=rc_get_w(rcfile);
  50.   rc_skip_cw(rcfile,lg,0);
  51.   /*}}}  */
  52.  
  53.   return(False);
  54. }
  55. /*}}}  */
  56. /*{{{  test_char_set*/
  57. public boolean test_char_set(int x,SetId setno)
  58. {
  59.   switch (setno)
  60.    { case alnum_set: return((boolean)isalnum(x));
  61.      case digit_set: return((boolean)isdigit(x));
  62.      case alpha_set: return((boolean)isalpha(x));
  63.      case upper_set: return((boolean)isupper(x));
  64.      case lower_set: return((boolean)islower(x));
  65.      case blank_set: return(x==' ' || x=='\t');
  66.      case xdigi_set: return((boolean)isxdigit(x));
  67.      case cntrl_set: return((boolean)iscntrl(x));
  68.      case punct_set: return((boolean)ispunct(x));
  69.      case print_set: return((boolean)isprint(x));
  70.      case space_set: return((boolean)isspace(x));
  71.      case graph_set: return((boolean)isgraph(x));
  72.      default:
  73.         if (setno>=0 && setno<set_used)
  74.            return((boolean)((1<<(x&7))&setlist[setno][x>>3]));
  75.         else
  76.            exit_origami(r_ocl_err,get_msg(F_INT_OCL,"set",setno));
  77.  
  78.    }
  79. }
  80. /*}}}  */
  81. /*{{{  set_copy*/
  82. public void set_copy(int to,int from)
  83. {
  84.   int i;
  85.  
  86.   for (i=0;i<SET_LG;i++)
  87.      setlist[to][i]=setlist[from][i];
  88. }
  89. /*}}}  */
  90.